from DBAction import DBAction


class Juju:
    def __init__(self, fanid, name='', level=1):
        self.fanid = fanid
        self.name = name
        self.level = level

    def check(self):
        db = DBAction('pocket48')
        result = db.data_inquiry_all('select count(1) from fans where fanid=%s', self.fanid)
        if result[0][0] == 0:
            db.data_operate('insert into fans(fanid,name,level) values(%s,%s,%s)', (self.fanid, self.name, self.level))
